package cn.ffcs.security.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;

import cn.ffcs.base.web.BaseAction;
import cn.ffcs.system.dict.model.Dict;
import cn.ffcs.system.dict.service.DictService;
import cn.ffcs.security.model.User;
import cn.ffcs.security.service.IUserService;

/**
 * 
 *  用户 action<br/> <table>
 * <tr>
 * <td>负责人/principal: </td>
 * <td colspan="2">liuzhh</td>
 * <tr>
 * <td>修改记录/revision:</td>
 * <td colspan="2"></td>
 * </tr>
 * <tr>
 * <td>日期:</td>
 * <td>修改人:</td>
 * <td>修改说明:</td>
 * </tr>
 * <tr>
 * <td></td>
 * <td></td>
 * <td></td>
 * </tr>
 * </table>
 * @author liuzhh
 * @version $Id$
 */
public class LogoutAction<U extends User> extends BaseAction<U>
{
    /** 网络标识 */
    private static final long serialVersionUID = -4686298088541775911L;
    /** 登录标识**/
    private static final String LOGIN_FLAG_="LOGIN";
    /** 用户标识**/
    private static final String LOGIN_USER_="LOGINUSER";
    /** 消息标识**/
    private static final String MESSAGE_="MSG";
    /** 消息标识**/
    private static final String FAIL_="fail";
    /** 业务POJO **/
    private U user;
    /** 业务列表数据 **/
    private List<U> users;
    /** 提示信息 **/
    private String message; 
    /** 用户服务**/
    private IUserService userService;
    
    /**
     * 用户登录校验
     */
    public String logout()
    {
        boolean bSucc=false;
        
        // 判断用户是否已登录
        User currUser = (User)getAppContextObject(LOGIN_USER_);
        if (currUser != null)
        {
            this.removeContextObject(LOGIN_USER_);
        }

        
        return SUCCESS;
    }
    
    /**
     * 获取业务POJO
     * @return
     */
    public U getUser()
    {
        return user;
    }

    /**
     * 设置业务POJO
     * @param user
     */
    public void setUser(U user)
    {
        this.user = user;
    }
    
    /**
     * 获取用户列表数据
     * @return
     */
    public List<U> getUsers()
    {
        return users;
    }
    
    /**
     * 设置业务用户列表
     * @param users
     */
    public void setUsers(List<U> users)
    {
        this.users = users;
    }

    /**
     * @return the message
     */
    public String getMessage()
    {
        return message;
    }

    /**
     * @param message the message to set
     */
    public void setMessage(String message)
    {
        this.message = message;
    }

    /**
     * @return the userService
     */
    public IUserService getUserService()
    {
        return userService;
    }

    /**
     * @param userService the userService to set
     */
    public void setUserService(IUserService userService)
    {
        this.userService = userService;
    }

}
